import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

// 模块化集成
const files = require.context('./modules', false, /\.js$/)
const routes = []
files.keys().forEach((key) => {
  if (key === './index.js') return
  const item = files(key).default
  routes.push(...item)
})

const router = new VueRouter({
  mode: 'history',
  // base: process.env.BASE_URL,
  routes
})
// 路由守卫
// router.beforeEach((to, from, next) => {})

// router.afterEach((to, from) => {})

export default router
